package demo;

import ru.yandex.clickhouse.BalancedClickhouseDataSource;
import ru.yandex.clickhouse.ClickHouseConnection;
import ru.yandex.clickhouse.settings.ClickHouseProperties;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Test1 {
    public static void main(String[] args) throws SQLException {
        ClickHouseProperties properties = new ClickHouseProperties();
        properties.setUser("defeulet");
        properties.setPassword("123456");

        BalancedClickhouseDataSource dataSource = new BalancedClickhouseDataSource("jdbc:clickhouse://hadoop10:8123/default", properties);

        ClickHouseConnection connection = dataSource.getConnection();

        PreparedStatement ps = connection.prepareStatement("insert into test values(?,?,?)");

        ps.setInt(1,1);
        ps.setString(2,"张三");
        ps.setInt(3,22);
        ps.executeQuery();

        ps.close();
        connection.close();

    }
}
